import { getChannelsAPI } from '../../api/channel';
import { SAVE_CHANNELS, UPDATE_CURRENT_ID } from './actionType';

export const getChannelsAction = () => {
  return async (dispacth) => {
    const result = await getChannelsAPI();

    dispacth({ type: SAVE_CHANNELS, payload: result.data.channels });
  };
};

export const updateCurrentIdAction = (id) => {
  return {
    type: UPDATE_CURRENT_ID,
    payload: id,
  };
};
